﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Wormhole.UI.Application.Controls.Generic
{
	/// <summary>
	/// Interaction logic for InputBox.xaml
	/// </summary>
	public partial class InputBox : Window
	{
		#region Properties

		#region Message
		private string _message;
		/// <summary>
		/// The user prompt message.
		/// </summary>
		public string Message
		{
			get
			{
				return this._message;
			}

			set
		    {
		        this._message = value;
				this.lblMessage.Content = string.Concat(this._message, ": ");
		    }
		}
		#endregion

		#region Value
		/// <summary>
		/// The value entered by the user.
		/// </summary>
		public string Value 
		{
			get
			{
				return this.txtValue.Text;
			}

			set
			{
				this.txtValue.Text = value;
				this.txtValue.SelectAll();
			}
		}
		#endregion

		#endregion

		#region Constructor
		/// <summary>
		/// Create a default instance of the class.
		/// </summary>
		public InputBox()
		{
			InitializeComponent();
			this.Title = "Input";
			this.Message = "Please enter a value";
			this.txtValue.Focus();
		}

		/// <summary>
		/// Create an  input box with the message specified.
		/// </summary>
		/// <param name="message">The input box user prompt.</param>
		public InputBox(string message) : this()
		{
			this.Message = message;
		}

		/// <summary>
		/// Create an input box with a custom title and message.
		/// </summary>
		/// <param name="title">The dialog box title.</param>
		/// <param name="message">The user prompt.</param>
		public InputBox(string title, string message)
			: this(message)
		{
			this.Title = title;
		}
		#endregion

		#region Event Handlers

		#region OK Click
		/// <summary>
		/// The OK button event handler.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void btnOK_Click(object sender, RoutedEventArgs e)
		{
			this.DialogResult = true;
			this.Close();
		}
		#endregion

		#region Cancel Click	
		/// <summary>
		/// The cancel button event handler.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void btnCancel_Click(object sender, RoutedEventArgs e)
		{
			this.DialogResult = false;
			this.Close();
		}
		#endregion

		#endregion
	}
}
